package com.nandi.emergencyinspection.api.response

import com.tbright.ktbaselibrary.base.BaseResponse

class BaseResponse<T> : BaseResponse<T>() {

    var data: T? = null

    var msg: String? = null

    var code: Int = 100

    var access_token: String? = null
    var token: String? = null
    var user_id: String? = null

    override fun isResponseSuccess(): Boolean {
        if (access_token != null) {
            return true
        }
        return code == 0 || code == 200
    }

    override fun getResponseData(): T? {
        if (access_token != null) {
            return access_token.plus(";$user_id") as T
        }
        if (token != null) {
            return token as T
        }
        return data
    }

    override fun getResponseMessage(): String? {
        return msg
    }

    override fun getResponseStatus(): Any? {
        if (access_token != null) {
            return 0
        }
        return code
    }
}